import { request } from "@/utils/http";
import { Key } from "react";
import type {
  ReqGetHospitalListResponse,
  ReqGetHospitalListParams,
  ProvinceCodeList,
  DepList,
  SchedulDetailList,
  ReqGetSchedulRuleListResponse,
  IhospitalShow,
} from "./model/hospitalListTypes";
/**
 * 分页获取医院列表
 * @param page 当前页
 * @param limit 每页条数
 * @returns
 */
export const reqGetHospitalList = ({
  page,
  limit,
  hoscode,
  hosname,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: ReqGetHospitalListParams) => {
  return request.get<any, ReqGetHospitalListResponse>(
    // path参数
    `/admin/hosp/hospital/${page}/${limit}`,
    // query 参数
    {
      params: {
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  );
};

/**
 * 获取省列表
 * @param province 固定参数 "province"
 * @returns ProvinceCodeList
 */
export const reqGetProvinceCodeList = (province: string = "province") => {
  return request.get<any, ProvinceCodeList>(
    // path参数
    `/admin/cmn/dict/findByDictCode/${province}`
  );
};

/**
 * 获取市和区域列表，参数是"10000"获取医院等级列表
 * @param parentId 父Id
 * @returns ProvinceCodeList
 */
export const reqGetCityOrDistrictCodeList = (parentId: string) => {
  return request.get<any, ProvinceCodeList>(
    // path参数
    `/admin/cmn/dict/findByParentId/${parentId}`
  );
};

/**
 * 获取科室列表
 * @param hoscode 医院编码 1000_0（北京人民医院） 才有数据
 * @returns DepList
 */
export const reqGetDepList = (hoscode: string) => {
  return request.get<any, DepList>(
    // path参数
    `/admin/hosp/department/${hoscode}`
  );
};

/**
 * 获取workDate排班日期的排班详细列表
 * @param hoscode 医院code   1000_0 只有（北京人民医院） 才有数据
 * @param depcode 200040878 只有 '专科' - '多发性硬化专科门诊'  才有数据
 * @param workDate
 * @returns
 */
export const reqGetSchedulDetailList = (
  hoscode: string,
  depcode: string,
  workDate: string
) => {
  return request.get<any, SchedulDetailList>(
    // path参数
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};

/**
 * 获取排班规则数据
 * @param param0  1000_0  200040878
 * @returns
 */
export const reqGetSchedulRuleList = ({
  page,
  limit,
  hoscode,
  depcode,
}: {
  page: number;
  limit: number;
  hoscode: string;
  depcode: string;
}) => {
  return request.get<any, ReqGetSchedulRuleListResponse>(
    // path参数
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};


/**
 * 更新医院状态
 * @param id 医院Id
 * @param status 医院状态
 * @returns 
 */
export const reqUpdateStatus = (id: string, status: number) => {
  return request.get<any, null>(
    // path参数
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  );
};



/**
 * 查看医院详情
 * @param id 医院Id
 * @returns 
 */
export const reqHospitalShow = (id: string) => {
  return request.get<any, IhospitalShow>(
    // path参数
    `/admin/hosp/hospital/show/${id}`
  );
};
